<?php
/**
 * Created by PhpStorm.
 * User: Kevin
 * Date: 2019/6/17
 * Time: 15:37
 */
namespace app\admin\controller;
use think\Db;
class Jifen extends Base
{
    public function index(){
        if(request()->isAjax ()){
            extract (input ());
            $map['conf_id'] = ['not in','9,10'];
            $Nowpage = input('page') ? input('page'):1;
            $limits = input("limit")?input("limit"):10;// 获取总条数;
            $count = Db::name('jifen_conf')
                ->where($map)
                ->count();
            $lists =  Db::name('jifen_conf')
                ->where($map)
                ->page($Nowpage,$limits)
                ->select ();
            return json(['code'=>220,'msg'=>'','count'=>$count,'data'=>$lists]);
        }
        return $this->fetch ('jifen/index');
    }


    public function jifenEdit(){
        extract (input());
        if(request ()->isPost ()){
           $res = Db::name('jifen_conf')
               ->where('conf_id',$id)
               ->update (['conf_rate'=>$rate ? $rate : null,'conf_time'=>date('Y-m-d H:i:s'),'conf_img'=>$img]);
           if($res){
               return json(['code'=>200,'msg'=>'编辑成功']);
           }else{
               return json(['code'=>100,'msg'=>'编辑失败']);
           }
        }
        $data = Db::name('jifen_conf')->where('conf_id',$id)->find();
        return $this->fetch ('jifen/jifen_edit',['data'=>$data]);
    }

}